/**
 * <copyright>
 * </copyright>
 *
 */
package lco.cRLanguage.impl;

import lco.cRLanguage.CRLanguagePackage;
import lco.cRLanguage.NumericFunctionExpression;
import lco.cRLanguage.StringValue;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>String Value</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link lco.cRLanguage.impl.StringValueImpl#getStringArg <em>String Arg</em>}</li>
 *   <li>{@link lco.cRLanguage.impl.StringValueImpl#getVariableArg <em>Variable Arg</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StringValueImpl extends MinimalEObjectImpl.Container implements StringValue
{
  /**
   * The default value of the '{@link #getStringArg() <em>String Arg</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getStringArg()
   * @generated
   * @ordered
   */
  protected static final String STRING_ARG_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getStringArg() <em>String Arg</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getStringArg()
   * @generated
   * @ordered
   */
  protected String stringArg = STRING_ARG_EDEFAULT;

  /**
   * The cached value of the '{@link #getVariableArg() <em>Variable Arg</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getVariableArg()
   * @generated
   * @ordered
   */
  protected NumericFunctionExpression variableArg;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected StringValueImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRLanguagePackage.Literals.STRING_VALUE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getStringArg()
  {
    return stringArg;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setStringArg(String newStringArg)
  {
    String oldStringArg = stringArg;
    stringArg = newStringArg;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.STRING_VALUE__STRING_ARG, oldStringArg, stringArg));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NumericFunctionExpression getVariableArg()
  {
    return variableArg;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetVariableArg(NumericFunctionExpression newVariableArg, NotificationChain msgs)
  {
    NumericFunctionExpression oldVariableArg = variableArg;
    variableArg = newVariableArg;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRLanguagePackage.STRING_VALUE__VARIABLE_ARG, oldVariableArg, newVariableArg);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setVariableArg(NumericFunctionExpression newVariableArg)
  {
    if (newVariableArg != variableArg)
    {
      NotificationChain msgs = null;
      if (variableArg != null)
        msgs = ((InternalEObject)variableArg).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.STRING_VALUE__VARIABLE_ARG, null, msgs);
      if (newVariableArg != null)
        msgs = ((InternalEObject)newVariableArg).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRLanguagePackage.STRING_VALUE__VARIABLE_ARG, null, msgs);
      msgs = basicSetVariableArg(newVariableArg, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRLanguagePackage.STRING_VALUE__VARIABLE_ARG, newVariableArg, newVariableArg));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRLanguagePackage.STRING_VALUE__VARIABLE_ARG:
        return basicSetVariableArg(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRLanguagePackage.STRING_VALUE__STRING_ARG:
        return getStringArg();
      case CRLanguagePackage.STRING_VALUE__VARIABLE_ARG:
        return getVariableArg();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRLanguagePackage.STRING_VALUE__STRING_ARG:
        setStringArg((String)newValue);
        return;
      case CRLanguagePackage.STRING_VALUE__VARIABLE_ARG:
        setVariableArg((NumericFunctionExpression)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.STRING_VALUE__STRING_ARG:
        setStringArg(STRING_ARG_EDEFAULT);
        return;
      case CRLanguagePackage.STRING_VALUE__VARIABLE_ARG:
        setVariableArg((NumericFunctionExpression)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRLanguagePackage.STRING_VALUE__STRING_ARG:
        return STRING_ARG_EDEFAULT == null ? stringArg != null : !STRING_ARG_EDEFAULT.equals(stringArg);
      case CRLanguagePackage.STRING_VALUE__VARIABLE_ARG:
        return variableArg != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (stringArg: ");
    result.append(stringArg);
    result.append(')');
    return result.toString();
  }

} //StringValueImpl
